package pers.cocoadel.springcloud.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.cocoadel.springcloud.service.PaymentService;



/**
 * @author rwby
 */
@RestController
@RequestMapping("/consumer")
//@DefaultProperties(commandProperties = {
//        @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "4000")})
public class OrderController
{
    private final PaymentService paymentService;

    @Autowired(required = false)
    public OrderController(PaymentService paymentService)
    {
        this.paymentService = paymentService;
    }

    @GetMapping("/payment/ok")
    public String getPaymentOk()
    {
        return paymentService.getPaymentOk();
    }

//    @HystrixCommand
    @GetMapping("/payment/time_out")
    public String getPaymentTimeOut()
    {
        return paymentService.getPaymentTimeOut();
    }
}
